﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>登录</title>
    @Styles.Render("~/Content/css")    
    <style>
        html,body{
            width:100%;
            height:100%;
            margin:0;
            padding:0;
            background-image:url(/images/login_bg.jpg);
        }
        .loginForm{
            float:right;
            margin-top:100px;
            margin-right:100px;
            width:300px;
            height:300px;
            background-color:#fff;
            padding:50px;
            padding-top: 10px;
            box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 2px 1px -1px rgba(0, 0, 0, 0.12);
        }
    </style>
</head>
<body>
    <div class="loginForm">
        <div class="row">
            <h1 style="text-align: center;font-size: 25px; margin-bottom: 25px;">登录</h1>
            <form id="loginForm" data-bv-trigger="mousemove keyup" data-bv-submitbuttons="[id='login']">
                <div class="row form-group">
                    <div class="col col-sm-12">
                        <i class="icon-user"></i>
                        <input type="text" class="form-control" name="name" id="name" placeholder="请输入账号" value="" />
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col col-sm-12">
                        <i class="icon-lock"></i>
                        <input type="password" class="form-control" name="password" id="password" placeholder="请输入密码" value="" />
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col col-sm-12">
                        <button class="btn btn-primary btn-block" id="login" type="button">登录</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
<script>
    $(function () {
        $("#login").click(function () {
            var n=$.trim($("#name").val())
            var p=$.trim($("#password").val())
            if(n==''){
                toastr.warning("请输入账号");
                return;
            }
            if (p == '') {
                toastr.warning("请输入密码");
                return;
            }
            $.ajax({
                url: '/api/account/login',
                type:'post',
                dataType: "json",
                data: { LoginName: n, Password: p },
                success: function (res) {
                    if (res.errcode == 0) {
                        _utility.userInfo(res.data);
                        $.cookie("token", res.data.Token, { path: '/' });
                        window.location.href = "/";
                    } else {
                        toastr.warning(res.errmsg);
                    }
                }
            });
        });
    });
</script>
</html>
